package com.neusoft.yuejian_01.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.neusoft.yuejian_01.activity.ClubDetailActivity;
import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.base.BaseAdapter;
import com.neusoft.yuejian_01.javabean.ClubBean;
import com.neusoft.yuejian_01.model.ConstPhoto;
import com.neusoft.yuejian_01.viewHolder.ClubViewHolder;

import java.util.List;

import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by Administrator on 2017/9/29.
 */

public class ClubAdapter extends BaseAdapter {

    public ClubAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_clublist, parent, false);
        ClubViewHolder viewHolder = new ClubViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        ClubViewHolder viewHolder = (ClubViewHolder) holder;
        final ClubBean clublist = (ClubBean) data.get(position);
        String clubInfo = clublist.getC_info();
        final String c_name = clublist.getC_name();
        final int c_id = clublist.getC_id();
        viewHolder.clubinfoView.setText(clubInfo);
        viewHolder.clubNameView.setText(c_name);
        final String clubPic = ConstPhoto.BASE_URL+ConstPhoto.ClubFile+clublist.getC_pic();
        Picasso.with(context)
                .load(clubPic)
               .placeholder(R.drawable.pic2)
                .into(viewHolder.clubImage);

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //启动新的activity(俱乐部详情列表)
                Intent intent = new Intent(context, ClubDetailActivity.class);
                intent.putExtra("c_id", c_id);
                intent.putExtra("c_name",c_name);
                context.startActivity(intent);
            }
        });
    }
}
